#define _CRT_SECURE_NO_WARNINGS 1
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
const int N = 1e5 + 10;
vector<int> g[N];
bitset<N> vis;

void dfs(int st) {
	queue<int> q;
	q.push(st);
	while (q.size()) {
		int x = q.front(); q.pop();
		if (vis[x]) continue;
		vis[x] = true;
		for (auto& y : g[x]) {
			if (vis[y]) continue;
			q.push(y);
		}
	}
}

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, m; cin >> n >> m;
	while (m--) {
		int u, v; cin >> u >> v;
		if (u != v) g[u].push_back(v);
	}
	dfs(1);
	for (int i = 1; i <= n; i++) {
		if (vis[i]) cout << i << " ";
	}
	cout << '\n';
	return 0;
}